package com.chain.BrotherExchange.data;

import com.chain.BrotherExchange.C;
import com.chain.BrotherExchange.data.model.AddLegalTenderOrder;
import com.chain.BrotherExchange.data.model.AlipayInfo;
import com.chain.BrotherExchange.data.model.AnnouncementList;
import com.chain.BrotherExchange.data.model.Appeal;
import com.chain.BrotherExchange.data.model.ApplyUnlcokList;
import com.chain.BrotherExchange.data.model.AuthenticationNumber;
import com.chain.BrotherExchange.data.model.BankCardInfo;
import com.chain.BrotherExchange.data.model.BannerList;
import com.chain.BrotherExchange.data.model.BaseResponseModel;
import com.chain.BrotherExchange.data.model.ChargeMoney;
import com.chain.BrotherExchange.data.model.ChargeMoneyDetails;
import com.chain.BrotherExchange.data.model.ChattingRecords;
import com.chain.BrotherExchange.data.model.CheckVersion;
import com.chain.BrotherExchange.data.model.CoinAssetsDetails;
import com.chain.BrotherExchange.data.model.CoinAssetsList;
import com.chain.BrotherExchange.data.model.CoinOrderList;
import com.chain.BrotherExchange.data.model.CoinTypeList;
import com.chain.BrotherExchange.data.model.CountryCodeList;
import com.chain.BrotherExchange.data.model.EntrustQueue;
import com.chain.BrotherExchange.data.model.ExtractCoinAddressList;
import com.chain.BrotherExchange.data.model.ExtractMoneyDetails;
import com.chain.BrotherExchange.data.model.GetttestApi;
import com.chain.BrotherExchange.data.model.LegalTenderAssetsDetails;
import com.chain.BrotherExchange.data.model.LegalTenderAssetsList;
import com.chain.BrotherExchange.data.model.LegalTenderBalance;
import com.chain.BrotherExchange.data.model.LegalTenderDealList;
import com.chain.BrotherExchange.data.model.LegalTenderOrderDetails;
import com.chain.BrotherExchange.data.model.LegalTenderOrderList;
import com.chain.BrotherExchange.data.model.LegalTenderUnitPrice;
import com.chain.BrotherExchange.data.model.LegalTenderUserInfo;
import com.chain.BrotherExchange.data.model.MarketPair;
import com.chain.BrotherExchange.data.model.MoneyRecordModel;
import com.chain.BrotherExchange.data.model.MyInvitationCode;
import com.chain.BrotherExchange.data.model.OtherDetails;
import com.chain.BrotherExchange.data.model.PayPalInfo;
import com.chain.BrotherExchange.data.model.ProcedureFee;
import com.chain.BrotherExchange.data.model.Quotation;
import com.chain.BrotherExchange.data.model.QuotationTypes;
import com.chain.BrotherExchange.data.model.SingleCoinBalance;
import com.chain.BrotherExchange.data.model.TethNumberModel;
import com.chain.BrotherExchange.data.model.TokenTradeModel;
import com.chain.BrotherExchange.data.model.TradingVolume;
import com.chain.BrotherExchange.data.model.TransferDetailsList;
import com.chain.BrotherExchange.data.model.UploadFiles;
import com.chain.BrotherExchange.data.model.UserAreaCode;
import com.chain.BrotherExchange.data.model.UserAssets;
import com.chain.BrotherExchange.data.model.UserInfo;
import com.chain.BrotherExchange.data.model.UserIsAuthentication;
import com.chain.BrotherExchange.data.model.UserLogin;
import com.chain.BrotherExchange.data.model.UserPayment;
import com.chain.BrotherExchange.data.model.VisualQuotation;
import com.chain.BrotherExchange.data.model.WeChatPayInfo;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import static com.chain.BrotherExchange.data.WebService.Helper.toRequestBody;

/**
 * 获取远程数据
 */
public class RemoteDataSource implements DataSource {

    private WebService mWebService = WebService.Helper.get();

    @Override
    public void homeBannerList(DataCallback<BannerList> callback) {
        mWebService.bannerList().enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new BannerList().error(code, message)))
        );
    }

    @Override
    public void announcementList(DataCallback<AnnouncementList> callback) {
        int type = C.API_ANNOUNCEMENT_TYPE, page = 1, rows = 20;
        mWebService.announcementList(type, page, rows)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new AnnouncementList().error(code, message)))
                );
    }

    @Override
    public void tradingVolume(DataCallback<TradingVolume> callback) {
        mWebService.tradingVolume().enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new TradingVolume().error(code, message))
        ));
    }

    @Override
    public void sdcQuotation(DataCallback<Quotation> callback) {
        mWebService.quotation(C.API_SDC_QUOTATION).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new Quotation().error(code, message)))
        );
    }

    @Override
    public void quotationType(DataCallback<QuotationTypes> callback) {
        mWebService.quotationTypes().enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new QuotationTypes().error(code, message)))
        );
    }

    @Override
    public void procedureFee(DataCallback<ProcedureFee> callback) {
        mWebService.procedureFee().enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new ProcedureFee().error(code, message))
        ));
    }

    @Override
    public void quotationInfo(int type, DataCallback<Quotation> callback) {
        mWebService.quotation(type).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new Quotation().error(code, message)))
        );
    }

    @Override
    public void login(String mobilePhone, String password, DataCallback<UserLogin> callback) {
        mWebService.login(mobilePhone, password, C.API_MOBILE_PHONE_TYPE)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new UserLogin().error(code, message)))
                );
    }

    @Override
    public void getUserAreaByMobilePhone(String mobilePhone, DataCallback<UserAreaCode> callback) {
        mWebService.getUserAreaByMobilePhone(mobilePhone, C.API_MOBILE_PHONE_TYPE)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new UserAreaCode().error(code, message)))
                );
    }

    @Override
    public void sendMessage(
            String region, String mobilePhone, int type, DataCallback<BaseResponseModel> callback) {
        mWebService.sendSms(region, mobilePhone, type)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
                );
    }

    @Override
    public void retrievePassword(
            String mobilePhone, String password, String code, DataCallback<BaseResponseModel> callback) {
        mWebService.forgetPassword(mobilePhone, password, code, C.API_MOBILE_PHONE_TYPE)
                .enqueue(new RetrofitCallback<>(callback, (errorCode, message) ->
                        callback.onResult(BaseResponseModel.e(message, errorCode)))
                );
    }

    @Override
    public void userAssets(String token, int uid, DataCallback<UserAssets> callback) {
        mWebService.userAssets(uid, token).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new UserAssets().error(code, message)))
        );
    }

    @Override
    public void userInfo(String token, int uid, DataCallback<UserInfo> callback) {
        mWebService.userInfo(uid, token).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new UserInfo().error(code, message)))
        );
    }

    @Override
    public void myInvitationCode(String token, int uid, DataCallback<MyInvitationCode> callback) {
        mWebService.myInvitationCode(uid, token).enqueue(new RetrofitCallback<>(callback,
                        (code, message) -> callback.onResult(new MyInvitationCode().error(code, message))
                )
        );
    }

    @Override
    public void authenticationNumber(int uid, DataCallback<AuthenticationNumber> callback) {
        mWebService.authenticationNumber(uid).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new AuthenticationNumber().error(code, message)))
        );
    }

    @Override
    public void realNamAuthentication(
            String token, int uid, String id, String name, String code, DataCallback<BaseResponseModel> callback) {
        mWebService.realNamAuthentication(uid, token, id, name, code)
                .enqueue(new RetrofitCallback<>(callback, (code1, message) ->
                        callback.onResult(BaseResponseModel.e(message, code1)))
                );
    }

    @Override
    public void userIsAuthentication(int uid, String token, DataCallback<UserIsAuthentication> callback) {
        mWebService.userIsAuthentication(uid, token)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        new UserIsAuthentication().error(code, message))
                );
    }

    @Override
    public void modifyTransactionPassword(
            String token, int uid, String newPassword, String confirmPassword, String code,
            DataCallback<BaseResponseModel> callback) {
        mWebService.modifyTransactionPassword(uid, token, newPassword, confirmPassword, code)
                .enqueue(new RetrofitCallback<>(callback, (errorCode, message) ->
                        callback.onResult(BaseResponseModel.e(message, errorCode))));
    }

    @Override
    public void countryCodeList(DataCallback<CountryCodeList> callback) {
        mWebService.countryCodeList().enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new CountryCodeList().error(code, message)))
        );
    }

    @Override
    public void allCoinTypeList(DataCallback<CoinTypeList> callback) {
        mWebService.coinTypeList().enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new CoinTypeList().error(code, message)))
        );
    }

    @Override
    public void checkVersion(DataCallback<CheckVersion> callback) {
        mWebService.checkVersion(C.API_ANDROID_SYSTEM).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new CheckVersion().error(code, message)))
        );
    }

    @Override
    public void modifyUserInfo(
            String token, int uid, String name, String portrait, DataCallback<BaseResponseModel> callback) {
        mWebService.modifyUserInfo(uid, token, name, portrait).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void modifyLoginPassword(
            String token, int uid, String oldPassword, String newPassword, String confirmPassword,
            String code, DataCallback<BaseResponseModel> callback) {
        mWebService.modifyLoginPassword(uid, token, newPassword, oldPassword,
                confirmPassword, code).enqueue(new RetrofitCallback<>(callback,
                (errorCode, message) -> callback.onResult(BaseResponseModel.e(message, errorCode)))
        );
    }

    @Override
    public void addCoinAddress(
            String token, int uid, int id, String address, String remark, DataCallback<BaseResponseModel> callback) {
        mWebService.addCoinAddress(token, uid, id, address, remark).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void extractAddressList(String token, int uid, DataCallback<ExtractCoinAddressList> callback) {
        mWebService.extractAddressList(uid, token).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new ExtractCoinAddressList().error(code, message)))
        );
    }

    @Override
    public void deleteExtractAddress(String token, int uid, String id, DataCallback<BaseResponseModel> callback) {
        mWebService.deleteExtractAddress(token, uid, id).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void cancelExtractMoney(String token, int uid, int id, DataCallback<BaseResponseModel> callback) {
        mWebService.cancelExtractMoney(uid, token, id)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
                );
    }

    @Override
    public void coinAssetsList(String token, int uid, DataCallback<CoinAssetsList> callback) {
        mWebService.coinAssetsList(uid, token)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new CoinAssetsList().error(code, message))));
    }

    @Override
    public void entrustQueue(String symbol, DataCallback<EntrustQueue> callback) {
        mWebService.entrustQueue(symbol).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new EntrustQueue().error(code, message))
        ));
    }

    @Override
    public void legalTenderAssetsList(String token, int uid, DataCallback<LegalTenderAssetsList> callback) {
        mWebService.legalTenderAssetsList(uid, token)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new CoinAssetsList().error(code, message))));
    }

    @Override
    public void coinOrderList(int uid, String token, int page, DataCallback<CoinOrderList> callback) {
        mWebService.coinOrderList(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new CoinOrderList().success(message)))
        );
    }

    @Override
    public void unfinishedCoinOrder(int uid, String token, int page, DataCallback<CoinOrderList> callback) {
        mWebService.unfinishedCoinOrder(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new CoinOrderList().success(message)))
        );
    }

    @Override
    public void cancelCoinOrder(
            int uid, String token, String id, String sign, String nonce,
            DataCallback<BaseResponseModel> callback) {
        mWebService.cancelCoinOrder(token, uid, id, sign, nonce).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void coinAssetsDetailsList(int uid, String token, int page, DataCallback<CoinAssetsDetails> callback) {
        mWebService.coinAssetsDetailsList(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new CoinAssetsDetails().error(code, message)))
        );
    }

    @Override
    public void chargeMoneyDetailsList(int uid, String token, int page, DataCallback<ChargeMoneyDetails> callback) {
        mWebService.chargeMoneyDetailsList(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new ChargeMoneyDetails().error(code, message)))
        );
    }

    @Override
    public void extractMoneyDetailsList(int uid, String token, int page, DataCallback<ExtractMoneyDetails> callback) {
        mWebService.extractMoneyDetailsList(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new ExtractMoneyDetails().error(code, message)))
        );
    }

    @Override
    public void transferDetailsList(int uid, String token, int page, DataCallback<TransferDetailsList> callback) {
        mWebService.transferDetailsList(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new TransferDetailsList().error(code, message)))
        );
    }

    @Override
    public void otherDetailsList(int uid, String token, int page, DataCallback<OtherDetails> callback) {
        mWebService.otherDetailsList(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new OtherDetails().error(code, message)))
        );
    }

    @Override
    public void extractMoney(
            int uid, String token, String id, String address, String amount, String realAmount,
            String gas, String code, String password, String phone, DataCallback<BaseResponseModel> callback) {

        mWebService.extractMoney(token, uid, id, address, amount, gas, realAmount,
                code, password, phone).enqueue(new RetrofitCallback<>(callback,
                (code1, message) -> callback.onResult(BaseResponseModel.e(message, code1)))
        );
    }

    @Override
    public void transferToCurrency(
            int uid, String token, String id, double number, DataCallback<BaseResponseModel> callback) {
        mWebService.transferToCurrency(token, uid, id, number).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void chargeMoney(int uid, String token, String id, DataCallback<ChargeMoney> callback) {
        mWebService.chargeMoney(token, uid, id).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new ChargeMoney().error(code, message)))
        );
    }

    @Override
    public void singleCoinBalance(int uid, String token, String id, DataCallback<SingleCoinBalance> callback) {
        mWebService.singleCoinBalance(uid, token, id).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new SingleCoinBalance().error(code, message)))
        );
    }

    @Override
    public void uploadFile(String base64, DataCallback<UploadFiles> callback) {
        mWebService.uploadFile(base64).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new UploadFiles().error(code, message)))
        );
    }

    @Override
    public void entrustOrder(
            int uid, String token, String symbol, int option, double onPrice, int type,
            double number, String sign, String nonce, DataCallback<BaseResponseModel> callback) {
        mWebService.entrustOrder(uid, token, symbol, option, onPrice, type, number, sign, nonce)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
                );
    }

    @Override
    public void register(
            String mobilePhone, String password, int region, String inviteCode, String code,
            DataCallback<BaseResponseModel> callback) {
        mWebService.register(mobilePhone, password, region, inviteCode, password,
                C.API_MOBILE_PHONE_TYPE, code).enqueue(new RetrofitCallback<>(
                callback, (code1, message) -> callback.onResult(BaseResponseModel.e(message, code1))
        ));
    }

    @Override
    public void gettestApiFirst(String phone, DataCallback<GetttestApi> callback) {
        mWebService.gettestApiFirst(phone).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new GetttestApi().error(code, message)))
        );
    }

    @Override
    public void gettestApiSecond(
            String phone, String challenge, String validate, String seccode, int status,
            DataCallback<BaseResponseModel> callback) {
        mWebService.gettestApiSecond(phone, challenge, validate, seccode, status).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void legalTenderDealList(
            int type, int tokenId, int page, DataCallback<LegalTenderDealList> callback) {
        mWebService.legalTenderDealList(type, tokenId, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new LegalTenderDealList().error(code, message)))
        );
    }

    @Override
    public void userPayment(int uid, String token, DataCallback<UserPayment> callback) {
        mWebService.userPayment(uid, token).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new UserPayment().error(code, message)))
        );
    }

    @Override
    public void setBankPayment(
            int uid, String token, String name, String bankName, String bankAddress,
            String bankNumber, String confirmNumber, String code, DataCallback<BaseResponseModel> callback) {
        mWebService.addBankPayment(uid, token, name, bankName, bankAddress, bankNumber,
                confirmNumber, code).enqueue(new RetrofitCallback<>(callback, (code1, message) ->
                callback.onResult(BaseResponseModel.e(message, code1)))
        );
    }

    @Override
    public void setAliPayPayment(
            int uid, String token, String name, String aliPay, String rqCode, String verifyCode,
            DataCallback<BaseResponseModel> callback) {
        mWebService.addAliPayment(uid, token, name, aliPay, rqCode, verifyCode)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
                );
    }

    @Override
    public void setWeChatPayment(
            int uid, String token, String name, String weChat, String rqCode, String verifyCode,
            DataCallback<BaseResponseModel> callback) {
        mWebService.addWeChatPayment(uid, token, name, weChat, rqCode, verifyCode)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
                );
    }

    @Override
    public void setPayPalPayment(
            int uid, String token, String name, String verifyCode, DataCallback<BaseResponseModel> callback) {
        mWebService.addPayPalPayment(uid, token, name, verifyCode)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
                );
    }

    @Override
    public void level2Certification(
            int uid, String token, String front, String reverse, String head, DataCallback<BaseResponseModel> callback) {
        mWebService.level2Certification(uid, token, front, reverse, head)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
                );
    }

    @Override
    public void legalTenderAssetsDetails(
            int uid, String token, int page, DataCallback<LegalTenderAssetsDetails> callback) {
        mWebService.legalTenderAssetsDetails(token, uid, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new LegalTenderAssetsDetails().error(code, message)))
        );
    }

    @Override
    public void transferToLegalTender(
            int uid, String token, String id, double number, DataCallback<BaseResponseModel> callback) {
        mWebService.transferToLegalTender(token, uid, id, number).enqueue(
                new RetrofitCallback<>(callback, (code, message) -> BaseResponseModel.e(message, code))
        );
    }

    @Override
    public void bankCardInfo(int uid, String token, DataCallback<BankCardInfo> callback) {
        mWebService.bankCardInfo(uid, token).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new BankCardInfo().error(code, message)))
        );
    }

    @Override
    public void aliPayInfo(int uid, String token, DataCallback<AlipayInfo> callback) {
        mWebService.aliPayInfo(uid, token).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new AlipayInfo().error(code, message)))
        );
    }

    @Override
    public void weChatPayInfo(int uid, String token, DataCallback<WeChatPayInfo> callback) {
        mWebService.weChatPayInfo(uid, token).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new WeChatPayInfo().error(code, message)))
        );
    }

    @Override
    public void payPalInfo(int uid, String token, DataCallback<PayPalInfo> callback) {
        mWebService.payPalInfo(uid, token).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new PayPalInfo().error(code, message)))
        );
    }

    @Override
    public void legalTenderOrderList(
            int uid, String token, int page, DataCallback<LegalTenderOrderList> callback) {
        mWebService.legalTenderOrderList(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new LegalTenderOrderList().error(code, message)))
        );
    }

    @Override
    public void cancelLegalTenderOrder(
            int uid, String token, int id, int type, DataCallback<BaseResponseModel> callback) {
        mWebService.cancelLegalTenderOrder(uid, token, id, type).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void confirmPayment(
            int uid, String token, int id, DataCallback<BaseResponseModel> callback) {
        mWebService.confirmPayment(uid, token, id).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void legalTenderUserInfo(int uid, DataCallback<LegalTenderUserInfo> callback) {
        mWebService.legalTenderUserInfo(uid).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new LegalTenderUserInfo().error(code, message)))
        );
    }

    @Override
    public void legalTenderUserDealList(
            int uid, int type, int page, DataCallback<LegalTenderDealList> callback) {
        mWebService.legalTenderUserDealList(uid, type, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new LegalTenderDealList().error(code, message)))
        );
    }

    @Override
    public void legalTenderOrderDetails(
            int uid, String token, String id, DataCallback<LegalTenderOrderDetails> callback) {
        mWebService.legalTenderOrderDetails(uid, token, id).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new LegalTenderOrderDetails().error(code, message))
        ));
    }

    @Override
    public void legalTenderAddOrder(
            int uid, String token, int id, double number, DataCallback<AddLegalTenderOrder> callback) {
        mWebService.legalTenderAddOrder(uid, token, id, number).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new AddLegalTenderOrder().error(code, message))
        ));
    }

    @Override
    public void legalTenderBalance(
            int uid, String token, int tokenId, DataCallback<LegalTenderBalance> callback) {
        mWebService.legalTenderBalance(uid, token, tokenId).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new LegalTenderBalance().error(code, message))
        ));
    }

    @Override
    public void legalTenderAppeal(
            int uid, String token, String tokenId, String orderId, int opt, String tokenName, String image,
            String mark, String remarks, DataCallback<Appeal> callback) {
        mWebService.legalTenderAppeal(uid, token, tokenId, opt, orderId, image, tokenName, remarks)
                .enqueue(new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(new Appeal().error(code, message)))
                );
    }

    @Override
    public void orderRelease(
            int uid, String token, int orderId, String password, String sign, String nonce,
            DataCallback<BaseResponseModel> callback) {
        mWebService.orderRelease(uid, token, orderId, password, sign, nonce).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void cancelAppeal(int uid, String token, int appealId, DataCallback<BaseResponseModel> callback) {
        mWebService.cancelAppeal(uid, appealId, token).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void publishTransaction(
            int uid, String token, int type, int tokenId, String tokenName, double price,
            double number, double premium, double acceptPrice, double minPrice, double maxPrice,
            boolean isVerify, String pays, String remark, DataCallback<BaseResponseModel> callback) {
        mWebService.publishTransaction(uid, token, type, tokenId, tokenName, price, number,
                (int) premium, acceptPrice, (int) minPrice, (int) maxPrice, isVerify ? 1 : 0, pays, remark).enqueue(
                new RetrofitCallback<>(callback, (code, message) ->
                        callback.onResult(BaseResponseModel.e(message, code)))
        );
    }

    @Override
    public void legalTenderUnitPrice(int tokenId, DataCallback<LegalTenderUnitPrice> callback) {
        mWebService.legalTenderUnitPrice(1, tokenId).enqueue(new RetrofitCallback<>(callback,
                (code, message) -> callback.onResult(new LegalTenderUnitPrice().error(code, message)))
        );
    }

    @Override
    public void editMyPublishTransactionOrderStatus(
            int uid, String token, int id, int statusId, DataCallback<BaseResponseModel> callback) {
        mWebService.editMyPublishTransactionOrderStatus(uid, token, id, statusId)
                .enqueue(new RetrofitCallback<>(callback, (code, message) -> BaseResponseModel.e(message, code)));
    }

    @Override
    public void editMyPublishTransactionOrder(
            int uid, String token, int id, double price, double number, double premium,
            double acceptPrice, double minPrice, double maxPrice, boolean isVerify, String pays,
            String remark, DataCallback<BaseResponseModel> callback) {
        mWebService.editMyPublishTransactionOrder(uid, token, id, price, number, (int) premium, acceptPrice,
                (int) minPrice, (int) maxPrice, isVerify ? 1 : 0, pays, remark).enqueue(
                new RetrofitCallback<>(callback, (code, message) -> BaseResponseModel.e(message, code))
        );
    }

    @Override
    public void visualQuotation(
            String symbol, String resolution, long fromDate, long toDate, DataCallback<VisualQuotation> callback) {

        WebService.Helper.kLine().visualQuotation(symbol, resolution, fromDate, toDate)
                .enqueue(new Callback<VisualQuotation>() {
                    @Override
                    public void onResponse(Call<VisualQuotation> call, Response<VisualQuotation> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<VisualQuotation> call, Throwable t) {

                    }
                });
    }

    @Override
    public void marketPairData(String symbol, DataCallback<MarketPair> callback) {
        mWebService.marketPairData(symbol).enqueue(new RetrofitCallback<>(
                callback, (code, message) -> callback.onResult(new MarketPair().error(code, message))
        ));
    }

    @Override
    public void chattingRecords(
            int uid, String token, String orderId, DataCallback<ChattingRecords> callback) {
        mWebService.chattingRecords(uid, token, orderId).enqueue(
                new Callback<ChattingRecords>() {
                    @Override
                    public void onResponse(Call<ChattingRecords> call, Response<ChattingRecords> response) {
                        callback.onResult(response.body());
                    }

                    @Override
                    public void onFailure(Call<ChattingRecords> call, Throwable t) {

                    }
                }
        );
    }

    @Override
    public void getTokenTrade(int uid, String token, int tokenId, DataCallback<TokenTradeModel> callback) {
        mWebService.getTokenTrade(uid, token, tokenId).enqueue(
                new RetrofitCallback<>(callback, (code, message) -> {
                    callback.onResult(new TokenTradeModel().error(code, message));
                })
        );
    }

    @Override
    public void getTokenTethNumber(int uid, String token, DataCallback<TethNumberModel> callback) {
        mWebService.getTokenTethNumber(uid, token).enqueue(
                new RetrofitCallback<>(callback, (code, m) ->
                        callback.onResult(new TethNumberModel().error(code, m)))
        );
    }

    @Override
    public void getMoneyRecord(
            int uid, String token, int page, int type, DataCallback<MoneyRecordModel> callback) {
        mWebService.getMoneyRecord(uid, token, page, 10, type).enqueue(
                new RetrofitCallback<>(callback, (code, m) -> callback.onResult(
                        new MoneyRecordModel().error(code, m)
                ))
        );
    }

    @Override
    public void lockToken(int uid, String token, int tokenId, DataCallback<BaseResponseModel> callback) {
        mWebService.lockToken(uid, token, tokenId).enqueue(new RetrofitCallback<>(callback, (code, m) ->
                BaseResponseModel.e(m, code)
        ));
    }

    @Override
    public void applyNode(int uid, String token, DataCallback<BaseResponseModel> callback) {
        mWebService.applyNode(uid, token).enqueue(new RetrofitCallback<>(callback, (code, m) ->
                BaseResponseModel.e(m, code)
        ));
    }

    @Override
    public void applyUnlock(int uid, String token, int tokenId, DataCallback<BaseResponseModel> callback) {
        mWebService.unlockApplyToken(uid, token, tokenId).enqueue(
                new RetrofitCallback<>(callback, (code, m) -> callback.onResult(BaseResponseModel.e(m, code)))
        );
    }

    @Override
    public void cancelApplyToken(int uid, String token, int id, DataCallback<BaseResponseModel> callback) {
        mWebService.cancelApplyToken(uid, token, id).enqueue(
                new RetrofitCallback<>(callback, (code, m) -> callback.onResult(BaseResponseModel.e(m, code)))
        );
    }

    @Override
    public void getApplyUnlockList(int uid, String token, int page, DataCallback<ApplyUnlcokList> callback) {
        mWebService.getApplyUnlockList(uid, token, page, 10).enqueue(
                new RetrofitCallback<>(callback, (code, m) -> new ApplyUnlcokList().error(code, m))
        );
    }
}
